"use client";

import { useEffect } from "react";
import { useRouter } from "next/navigation";

export default function HomePage() {
  const router = useRouter();
  
  useEffect(() => {
    const token = localStorage.getItem("accessToken");
    const expStr = localStorage.getItem("accessTokenExpiresAt");
    const exp = expStr ? Number(expStr) : 0;
    const isExpired = !exp || Date.now() >= exp;
    
    if (!token || isExpired) {
      localStorage.removeItem("accessToken");
      localStorage.removeItem("accessTokenExpiresAt");
      router.replace("/auth/login");
    } else {
      router.replace("/dashboard");
    }
  }, [router]);
  
  return null;
}